package bocchi.card;

import bocchi.base.BaseCustomCard;
import bocchi.BocchiCore;
import bocchi.base.BaseCustomPower;
import bocchi.general.Util;
import com.evacipated.cardcrawl.mod.stslib.actions.common.SelectCardsAction;
import com.megacrit.cardcrawl.actions.utility.NewQueueCardAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.powers.AbstractPower;

public class Ventriloquist extends BaseCustomCard {
    private static final String RAW_ID = Ventriloquist.class.getSimpleName();
	public static final String GAME_ID = BocchiCore.getGameID(RAW_ID);

    public Ventriloquist() {
        super(RAW_ID);
    }

    @Override
    public void use(AbstractPlayer player, AbstractMonster monster) {
        BaseCustomPower power = new BaseCustomPower(RAW_ID, AbstractPower.PowerType.BUFF, player, magicNumber) {
            @Override
            public void updateDescription() {
                description = String.format(descriptions[0], amount);
            }

            @Override
            public void atStartOfTurn() {
                flash();
                String text = String.format("选择%d张牌打出并消耗", amount);
                addToTop(new SelectCardsAction(player.drawPile.group, amount, text, true, card -> true, cards -> {
                    for (AbstractCard card : cards) {
                        card.exhaust = true;
                        AbstractDungeon.player.drawPile.group.remove(card);
                        AbstractDungeon.getCurrRoom().souls.remove(card);
                        addToBot(new NewQueueCardAction(card, true, false, true));
                    }
                }));
            }
        };

        Util.applyPower(player, player, power);
    }
}
